<?php

namespace addons\paotui;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Paotui extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'paotui',
                'title'   => '同城跑腿',
                'icon'    => 'fa fa-graduation-cap',
                'sublist' => [
                    [
                        "name"    => "paotui/post",
                        "title"   => "订单管理",
                        'icon'    => 'fa fa-envelope-square',
                        'sublist' => [
                            ["name" => "paotui/post/index", "title" => "查看",],
                            ["name" => "paotui/post/order", "title" => "订单轨迹",],
                            ["name" => "paotui/post/change_poster", "title" => "更换骑手",],
                            ["name" => "paotui/post/hand_dispatch", "title" => "手动指派",],
                        ]
                    ],
                    [
                        "name"    => "paotui/base_poster",
                        "title"   => "骑手管理",
                        'icon'    => 'fa fa-motorcycle',
                        'sublist' => [
                            [
                                "name" => "paotui/poster",
                                "title" => "骑手管理",
                                'sublist'=>[
                                    ["name" => "paotui/poster/index", "title" => "查看",],
                                    ["name" => "paotui/poster/add", "title" => "添加",],
                                    ["name" => "paotui/poster/edit", "title" => "编辑",],
                                    ["name" => "paotui/poster/del", "title" => "删除",],
                                ]
                            ],
                            [
                                "name" => "paotui/posternotice",
                                "title" => "骑手通知",
                                'sublist'=>[
                                    ["name" => "paotui/posternotice/index", "title" => "查看",],
                                    ["name" => "paotui/posternotice/add", "title" => "添加",],
                                    ["name" => "paotui/posternotice/edit", "title" => "编辑",],
                                    ["name" => "paotui/posternotice/del", "title" => "删除",],
                                ]
                            ],
                            [
                                "name" => "paotui/posterapply",
                                "title" => "骑手申请",
                                'sublist'=>[
                                    ["name" => "paotui/posterapply/index", "title" => "查看",],
                                    ["name" => "paotui/posterapply/check", "title" => "审核通过",],
                                    ["name" => "paotui/posterapply/cancel", "title" => "拒绝",],
                                ]
                            ],
                            [
                                "name" => "paotui/posterlevel",
                                "title" => "骑手等级",
                                'sublist'=>[
                                    ["name" => "paotui/posterlevel/index", "title" => "查看",],
                                    ["name" => "paotui/posterlevel/add", "title" => "添加",],
                                    ["name" => "paotui/posterlevel/edit", "title" => "编辑",],
                                    ["name" => "paotui/posterlevel/del", "title" => "删除",],
                                ]
                            ],
                        ]
                    ],
                    [
                        "name"    => "paotui/base_member",
                        "title"   => "用户管理",
                        'icon'    => 'fa fa-user-o',
                        'sublist' => [
                            [
                                "name" => "paotui/member",
                                "title" => "用户管理",
                                'sublist'=>[
                                    ["name" => "paotui/member/index", "title" => "查看",],
                                    ["name" => "paotui/member/add", "title" => "添加",],
                                    ["name" => "paotui/member/edit", "title" => "编辑",],
                                    ["name" => "paotui/member/del", "title" => "删除",],
                                ]
                            ],
                            [
                                "name" => "paotui/level",
                                "title" => "用户等级",
                                'sublist'=>[
                                    ["name" => "paotui/level/index", "title" => "查看",],
                                    ["name" => "paotui/level/add", "title" => "添加",],
                                    ["name" => "paotui/level/edit", "title" => "编辑",],
                                    ["name" => "paotui/level/del", "title" => "删除",],
                                ]
                            ],
                        ]
                    ],
                    [
                        "name"    => "paotui/brokerage",
                        "title"   => "财务结算",
                        'icon'    => 'fa fa-cny',
                        'sublist' => [
                            [
                                "name" => "paotui/posterextract",
                                "title" => "提现列表",
                                'sublist' => [
                                    ["name" => "paotui/posterextract/index","title" => "查看",],
                                    ["name" => "paotui/posterextract/check","title" => "添加",],
                                    ["name" => "paotui/posterextract/cancel","title" => "编辑",],
                                ],
                            ]
                        ],
                    ],
                    [
                        "name"    => "paotui/socket_config",
                        "title"   => "跑腿配置",
                        'icon'    => 'fa fa-gears',
                        'sublist' => [
                            [
                                "name" => "paotui/price",
                                "title" => "价格管理",
                                'sublist' => [
                                    ["name" => "paotui/generalprice/index","title" => "基础价格",'icon'=> 'fa fa-jpy','ismenu'=>1],
                                    ["name" => "paotui/distanceprice/index","title" => "路程价格管理",'icon'=> 'fa fa-navicon','ismenu'=>1],
                                    ["name" => "paotui/weightprice/index","title" => "重量价格管理",'icon'=> 'fa fa-balance-scale','ismenu'=>1],
                                    ["name" => "paotui/extraprice/index","title" => "溢价价格管理",'icon'=> 'fa fa-flask','ismenu'=>1],
                                ],
                            ],
                            [
                                "name" => "paotui/brokeragescale/index",
                                "title" => "佣金/保价金额配置",
                                'icon'=> ' fa fa-gear',
                                'ismenu'=>1
                            ],
                            [
                                "name" => "paotui/times",
                                "title" => "预约时间段管理",
                                'sublist' => [
                                    ["name" => "paotui/times/index","title" => "查看",],
                                    ["name" => "paotui/times/add","title" => "添加",],
                                    ["name" => "paotui/times/edit","title" => "编辑",],
                                    ["name" => "paotui/times/del","title" => "删除",],
                                ],
                            ],
                            [
                                "name" => "paotui/goods_type",
                                "title" => "物品类型管理",
                                'sublist' => [
                                    ["name" => "paotui/goods_type/index","title" => "查看",],
                                    ["name" => "paotui/goods_type/add","title" => "添加",],
                                    ["name" => "paotui/goods_type/edit","title" => "编辑",],
                                    ["name" => "paotui/goods_type/del","title" => "删除",],
                                ],
                            ],

                            [
                                "name" => "paotui/socket_config/index",
                                "title" => "骑手推送配置",
                                'icon'=> 'fa fa-bell-o',
                                'ismenu'=>1
                            ],
                        ],
                    ],
                    [
                        "name"    => "paotui_mini",
                        "title"   => "小程序配置",
                        'icon'    => 'fa fa-comments',
                        'sublist' => [
                            [
                                "name" => "paotui/mini/index",
                                "title" => "小程序配置",
                                'icon'=> 'fa fa-gear',
                                'ismenu'=>1
                            ],
                            [
                                "name" => "paotui/mini/pay",
                                "title" => "支付配置",
                                'icon'=> 'fa fa-cc-paypal',
                                'ismenu'=>1
                            ],
                            [
                                "name" => "paotui/template_ids",
                                "title" => "订阅消息",
                                'sublist' => [
                                    ["name" => "paotui/template_ids/index","title" => "查看",],
                                    ["name" => "paotui/template_ids/edit","title" => "编辑",],
                                ],
                            ],
                        ]
                    ],
                    [
                        "name"    => "paotui/market",
                        "title"   => "营销管理",
                        'icon'    => 'fa fa-bullhorn',
                        'sublist' => [
                            ["name" => "paotui/article", "title" => "文章列表",
                                'sublist' => [
                                    ["name" => "paotui/article/index","title" => "查看",],
                                    ["name" => "paotui/article/add","title" => "添加",],
                                    ["name" => "paotui/article/edit","title" => "编辑",],
                                    ["name" => "paotui/article/del","title" => "删除",],
                                ],
                            ],
                        ]
                    ],

                ]
            ]
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("paotui");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("paotui");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("paotui");
        return true;
    }

    public function appInit()
    {
        if (request()->isCli()) {
            \think\Console::addDefaultCommands([
                'addons\paotui\library\GatewayWorker\start'
            ]);
        }
    }

}
